import { DailyItem } from "./DailyItem";
import { ResouceConst } from "../../../../component/gconst/ResouceConst";
import { ImagesConst } from "../../../resource/ImagesConst";
import { GTextFormat } from "../../../../common/GTextFormat";
import { FontUtil } from "../../../../common/font/FontUtil";
import { FilterConst } from "../../../../component/gconst/FilterConst";
import { LoaderHelp } from "../../../../common/display/LoaderHelp";
import { ResFileConst } from "../../../resource/ResFileConst";
import { GlobalClass } from "../../../../../com/mui/core/GlobalClass";
import { DailyInfo } from "../../../model/DailyInfo";
import { HTMLUtil } from "../../../../../com/gengine/utils/HTMLUtil";
import { ScaleBitmap } from "../../../../../com/mui/display/ScaleBitmap";
//class DailyActionDegreeItem
    
    export  class DailyActionDegreeItem extends DailyItem
    {
        constructor()
        {
            super();
            return;
        }

        public /* override */ initUI(): void
        {
            super.initUI();
            this._nameBg = ResouceConst.getScaleBitmap(ImagesConst.WindowCenterB);
            this._nameBg.width = 95;
            this._nameBg.height = 32;
            this._nameBg.x = 2;
            this._nameBg.y = 3;
            addChildAt(this._nameBg, 0);
            _itemName.defaultTextFormat = new GTextFormat(FontUtil.xingkaiName, 20, 16187136, false);
            _itemName.filters = [FilterConst.glowFilter];
            _itemName.y = 8;
            _itemName.x = _itemName.x + 9;
            this._itemCountTxt = new Object /* flash.text.TextField */();
            this._itemCountTxt.autoSize = flash.text.TextFieldAutoSize.LEFT;
            this._itemCountTxt.textColor = 11464703;
            this._itemCountTxt.width = 120;
            this._itemCountTxt.height = 18;
            this._itemCountTxt.mouseEnabled = false;
            this._itemCountTxt.x = this._nameBg.x + this._nameBg.width + 10;
            this._itemCountTxt.y = 4;
            this._itemCountTxt.filters = [FilterConst.nameGlowFilter];
            addChild(this._itemCountTxt);
            this._itemDesTxt = new Object /* flash.text.TextField */();
            this._itemDesTxt.autoSize = flash.text.TextFieldAutoSize.LEFT;
            this._itemDesTxt.textColor = 16776960;
            this._itemDesTxt.width = 200;
            this._itemDesTxt.height = 18;
            this._itemDesTxt.mouseEnabled = false;
            this._itemDesTxt.x = this._itemCountTxt.x;
            this._itemDesTxt.y = 20;
            this._itemDesTxt.filters = [FilterConst.nameGlowFilter];
            addChild(this._itemDesTxt);
            removeChild(_itemTime);
            removeChild(_itemLevel);
            _itemOpt.x = 285;
            _itemOpt.y = 20;
            _flyFoot.y = _itemOpt.y;
            this._completeIcon = new Object /* flash.display.Bitmap */();
            this._completeIcon.x = _itemOpt.x + 15;
            this._completeIcon.y = 4;
            _line.y = (this.height - 1);
            LoaderHelp.addResCallBack(ResFileConst.daily, this.onDailyResLoadedHandler);
            return;
        }

        /* internal  */onDailyResLoadedHandler(): void
        {
            this._completeIcon.bitmapData = GlobalClass.getBitmapData(ImagesConst.DailyComIcon);
            return;
        }

        public /* override */ updateData(arg1: DailyInfo): void
        {
            this._countColor = "#00ff00";
            super.updateData(arg1);
            if (_info.condition != 2) 
            {
                if (_info.condition != 3) 
                {
                    _itemName.htmlText = HTMLUtil.addColor(arg1.name, "#f6ff00");
                }
                else 
                {
                    this._countColor = "#8e8e8e";
                }
            }
            else 
            {
                this._countColor = "#C688C9";
            }
            this._itemCountTxt.htmlText = HTMLUtil.addColor(arg1.name, this._countColor);
            if (_info.countTotal != 0) 
            {
                this._itemCountTxt.htmlText = this._itemCountTxt.htmlText + HTMLUtil.addColor("(" + _info.count + "/" + _info.countTotal + ")", this._countColor);
            }
            this._itemDesTxt.htmlText = HTMLUtil.addColor(arg1.des, _color);
            if (_info.hasComplete) 
            {
                if (!contains(this._completeIcon)) 
                {
                    this.addChild(this._completeIcon);
                }
            }
            else if (this.contains(this._completeIcon)) 
            {
                removeChild(this._completeIcon);
            }
            return;
        }

        public /* override */ get width(): number
        {
            return 337;
        }

        public /* override */ get height(): number
        {
            return 39;
        }

        /* internal */ /* var */_nameBg: ScaleBitmap;

        /* internal */ /* var */_itemCountTxt: Object /* flash.text.TextField */;

        /* internal */ /* var */_itemDesTxt: Object /* flash.text.TextField */;

        /* internal */ /* var */_completeIcon: Object /* flash.display.Bitmap */;

        /* internal */ /* var */_countColor: string="#00ff00";
    }
